## setup framework for 2 factors and response variable fertilizer<- as.factor(rep(1:3, each=12)) soil_type <- as.factor(rep(c(1,2,3), each=4, times = 3)) growth <- c(130, 155, 74, 180, 34, 40, 80, 75, 20, 70, 82, 58, 150, 188, 159, 126, 136, 122, 106, 115, 25, 70, 58, 45, 138, 110, 168, 160, 174, 120, 150, 139, 96, 104, 82, 60) y<- data.frame(fertilizer,soil_type,growth) ## apply a linear model yfit <- lm(growth ~ fertilizer+soil_type+fertilizer*soil_type, y) ## compute the analysis of variance table anova(yfit)